﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using A2DFramework.OSGI;
using OrderModule.PublicInterfaces;
using System.Runtime.Remoting;
using A2DFramework.OSGI.Processors;
using OrderModule.PublicInterfaces.Dtos;
using A2DFramework.OSGI.BundleContexts;
using System.Threading;

namespace DemoConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread.Sleep(2000);

            BundleRuntime runtime = new BundleRuntime();
            runtime.Start();
            Console.WriteLine("Server 1 Started");


            BundleContext ctx = BundleContext.Current;

            

            while (true)
            {
                Thread.Sleep(500);
                IOrderProcessor processor = (IOrderProcessor)ctx.GetProvidedService(typeof(IOrderProcessor).FullName);
                OrderDto order = new OrderDto();
                Guid id = processor.PlaceOrder(order);
                Console.WriteLine(id.ToString());
            }

            Console.ReadKey();
            runtime.Stop();
            runtime.Dispose();
            runtime = null;
        }
    }
}